import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;

import 'action.dart';
import 'state.dart';

Widget buildView(
    BootGuideState state, Dispatch dispatch, ViewService viewService) {
  Widget genTab(int index) {
    return Scaffold(
        body: Stack(
      children: <Widget>[
        Image.asset('assets/images/intro$index.png'),
        Align(
            alignment: Alignment.bottomCenter,
            child: Padding(
                padding: EdgeInsets.only(bottom: 50),
                child: Wrap(
                  spacing: 4,
                  children: <Widget>[
                    Container(
                        width: 6,
                        height: 6,
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          color: index == 1 ? Colors.black12 : Colors.black54,
                        )),
                    Container(
                        width: 6,
                        height: 6,
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          color: index == 2 ? Colors.black12 : Colors.black54,
                        )),
                    Container(
                        width: 6,
                        height: 6,
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          color: index == 3 ? Colors.black12 : Colors.black54,
                        )),
                    Container(
                        width: 6,
                        height: 6,
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          color: index == 4 ? Colors.black12 : Colors.black54,
                        )),
                  ],
                ))),
        Align(
            alignment: Alignment.bottomCenter,
            child: index == 4
                ? Padding(
                    padding: EdgeInsets.only(bottom: 90),
                    child: FlatButton(
                      padding:
                          EdgeInsets.symmetric(horizontal: 40, vertical: 12),
                      color: Colors.orange,
                      textColor: Colors.yellow,
                      child: Text(
                        '立即体验',
                        style: TextStyle(color: Colors.white),
                      ),
                      shape: RoundedRectangleBorder(
                          side: BorderSide(
                            color: Colors.white,
                            width: 0,
                          ),
                          borderRadius: BorderRadius.circular(20)),
                      onPressed: () {
                        dispatch(BootGuideActionCreator.onDone());
                      },
                    ))
                : null),
      ],
    ));
  }

  return Scaffold(
    body: PageView(
      controller: state.controller,
      onPageChanged: (index) => print(index),
      children: <Widget>[
        genTab(1),
        genTab(2),
        genTab(3),
        genTab(4),
      ],
    ),
  );
}
